package  com.greensoftcodeplus.redislog.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

public class ResolvingArgsList {

    public static String ResolvingArgs(Object o) {
        String ret = "";
        Object object = null;
            try {

                //RPUSH
                if (o instanceof byte[][]) {
                    String jsonParam ="";
                    byte[][] a = (byte[][]) o;
                    object = ResolvingFun.UnSerializeJson((byte[]) a[0]);
                    List<Object> list= (List<Object>) object;
                    int size=list.size();
                    String className = object.getClass().getName();
                    jsonParam+="[";
                    jsonParam+="\""+className+"\""+",";
                    jsonParam+="[";
                    int i=0;
                    for (Object subObject:list){
                        jsonParam+="[";
                        String objclassName= subObject.getClass().getName();
                        jsonParam+= "\""+objclassName+"\""+","  +JSONObject.toJSONString(subObject);
                        jsonParam+="]";
                        if (i<size-1)  jsonParam+=",";
                        i++;
                    }
                    jsonParam+="]";
                    jsonParam+="]";
                    jsonParam= jsonParam.replace("\"","\\\"");
                    jsonParam= "\""+jsonParam+"\"";

                    ret += jsonParam+ " ";
                }


            } catch (Exception e) {
               ret="";
            }

        return ret;
    }
}
